package org.zjt.java.demo.config.security;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Set;

public class SecurityUser implements UserDetails {

    private static final long serialVersionUID = 1L;

    private Long id;
    private String username;
    private String password;
    private String email;
    private Date passwordLastResetTime;
    private byte status;
    private Set<GrantedAuthority> authorities;

    private Set<String> authorizeURLs;

    private Set<String> authorizeRoles;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public void setAuthorities(Set<GrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    public Set<String> getAuthorizeURLs() {
        return authorizeURLs;
    }

    public void setAuthorizeURLs(Set<String> authorizeURLs) {
        this.authorizeURLs = authorizeURLs;
    }

    public Set<String> getAuthorizeRoles() {
        return authorizeRoles;
    }

    public void setAuthorizeRoles(Set<String> authorizeRoles) {
        this.authorizeRoles = authorizeRoles;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getPasswordLastResetTime() {
        return passwordLastResetTime;
    }

    public void setPasswordLastResetTime(Date passwordLastResetTime) {
        this.passwordLastResetTime = passwordLastResetTime;
    }

    public byte getStatus() {
        return status;
    }

    public void setStatus(byte status) {
        this.status = status;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
